// pages/eventdetails/eventdetails.js
var util = require('../../utils/util.js');
var commonService = require('../../services/commonService.js');
var activityService = require('../../services/activityService.js');
var WxParse = require('../../wxParse/wxParse.js');
//获取应用实例
var app = getApp()
Page({
  data: {
    isDone: false,
  },
  onLoad: function (options) {
    var id = options.id;
    var group_id = options.group_id;

    var that = this;

    that.setData({
      id:id,
      group_id:group_id
    })
    activityService.getActivityDetail({
      id: id,
      success: function (res) {
        var data = res
        // date.replace(/-/g, "/")
        data.active_time_start = util.makeDateTimeToPretty(new Date(data.active_time_start.replace(/-/g, "/")), true);
        data.active_time_end = util.makeDateTimeToPretty(new Date(data.active_time_end.replace(/-/g, "/")), true);
        data.remainJoinNum = data.volunteer_num - data.join_num;
        that.setData({
          mainInfo: data,
          activity_id: id
        })
        WxParse.wxParse('description', 'html', that.data.mainInfo.description, that, 5);
      }
    })
  },
  onReady: function () {
    // 页面渲染完成
  },
  onShow: function () {
    // 页面显示
  },
  onHide: function () {
    // 页面隐藏
  },
  onUnload: function () {
    // 页面关闭
  },
  joinMemberList:function(e){
    var that = this;
    wx.navigateTo({
      url: '../joinMemberList/joinMemberList?aid=' + that.data.activity_id + '&gid=' + that.data.group_id,
    })
  }
  
})